<template>
  <div>
    <van-cell title="搜索历史">
      <van-icon name="delete-o" v-if="!isDEl" @click="isDEl = true"></van-icon>
      <div v-else>
        <span @click="$store.commit('SET_HISTORIES', [])">全部删除</span> &nbsp;
        <span @click="isDEl = false">完成</span>
      </div>
    </van-cell>
    <van-cell
      @click="$emit('update-keywords', item)"
      v-for="item in $store.state.histories"
      :key="item"
      :title="item"
    >
      <van-icon
        name="close"
        v-if="isDEl"
        @click="
          $store.commit(
            'SET_HISTORIES',
            $store.state.histories.filter((i) => item !== i)
          )
        "
      />
    </van-cell>
  </div>
</template>

<script>
export default {
  name: "searchHistory",
  data() {
    return {
      isDEl: false
    };
  }
};
</script>

<style></style>
